<template>
    <div>
        <el-table :data="tableData" style="width: 100%">
            <el-table-column label="序号" type="index" width="150px"> </el-table-column>
            <el-table-column label="宿舍名" prop="name"> </el-table-column>
            <el-table-column label="宿舍编号" prop="number"> </el-table-column>
            <el-table-column label="姓名" prop="stuname"> </el-table-column>
            <!-- <el-table-column>
                <template slot-scope="scope">
                    <el-button size="mini" type="danger" @click="handelDelete(scope.$index, scope.row)">删除</el-button>
                </template>
            </el-table-column> -->
        </el-table>
        <div class="block">
            <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="currentPage"
                :page-sizes="[5, 10, 20, 40]"
                :page-size="pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="tableData.length"
            >
            </el-pagination>
        </div>
    </div>
</template>
<script>
export default {
    data() {
        return {
            tableData: [],
            currentPage: 1,
            pageSize: 10,
        };
    },
    methods: {
        async susheList() {
            const res = await this.getJSON(`/dormitory/findall?current=${this.currentPage}&size=${this.pageSize}`);
            console.log(res);
            this.tableData = res.data.records;
        },
        // 当前页
        handleSizeChange: function(size) {
            this.pagesize = size;
            console.log(this.pagesize); //每页下拉显示数据
        },
        handleCurrentChange: function(currentPage) {
            this.currentPage = currentPage;
            console.log(this.currentPage); //点击第几页
        },
    },
    created() {
        this.susheList();
    }
};
</script>
<style scoped></style>
